package com.yylany.controller;

import com.yylany.enums.ResultEnum;
import com.yylany.service.SpecificationService;
import com.yylany.vo.SpecificationResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Description: pinyougou
 *
 * @author <a href="mailto:17777502615@163.com">yaoyonglong</a>
 * @date 2018/12/19
 * @since 1.0.0
 */
@RestController
@RequestMapping
public class SpecificationController {

    @Autowired
    private SpecificationService specificationService;

    /**
     * 通过CategoryId 查询所有的属性
     *
     * @param catid CategoryId
     * @return SpecificationResult
     */
    @GetMapping("/specifications/{catid}")
    public SpecificationResult specifications(@PathVariable("catid") int catid) {
        List<Map<String, Object>> specifications = specificationService.specifications(catid);
        SpecificationResult brandsResult = new SpecificationResult(ResultEnum.CATEGORY_SUCCESS.getErrno(), ResultEnum.CATEGORY_SUCCESS.getErrmsg(), specifications);
        return brandsResult;
    }

}
